"""
业务日志 | 模型
"""

from pydantic import BaseModel

import utils.enum_utils as enum
from my_typing import *
from utils.validator_utils.pydantic_validator.field import (
    CharField,
    IntegerField,
    ListField,
    NormalField,
)


class BizLog(BaseModel):
    """ 业务日志 | Model """

    code_file: str = CharField(..., title="代码文件", max_length=32)
    code_line: int = IntegerField(..., title="代码行号", min_value=1, max_value=8192)
    code_path: str = CharField(..., title="代码路径", max_length=64)
    log_level: enum.LoguruLogLevel = CharField(..., title="日志级别")
    log_line: int = IntegerField(..., title="日志行号", min_value=1)
    log_time: datetime = NormalField(..., title="日志时间")
    message: str = CharField(..., title="日志信息")
    process_id: int = IntegerField(..., title="进程 ID", min_value=1, max_value=2 ** 32 - 1)
    thread_id: int = IntegerField(..., title="线程 ID", min_value=1, max_value=2 ** 32 - 1)


class BizLogFile(BaseModel):
    """ 业务日志文件 | Model """

    file_date: date = NormalField(..., title="文件日期")
    file_name: str = CharField(..., title="文件名", max_length=32)
    file_size: int = IntegerField(..., title="文件大小（Bytes）")
    log_count: int = IntegerField(..., title="日志条数")
    log_list: list[BizLog] = ListField(..., title="业务日志列表")
